//
//  ClassifyRightCollectionViewCell.m
//  A段 准备
//
//  Created by 凯 on 15/7/11.
//  Copyright (c) 2015年 zhoukaidong. All rights reserved.
//

#import "ClassifyRightCollectionViewCell.h"
#import "ClassifyModel.h"
#import "BaseHeader.h"
#import "UIImageView+WebCache.h"

@implementation ClassifyRightCollectionViewCell


- (void)dealloc
{
    [_Image1 release];
    [_Image2 release];
    [_Image3 release];
    [_Image4 release];
    [_Image5 release];
    [_Image6 release];
    [_namelabel release];
    [_informlabel release];
    [_floorview release];
    [super dealloc];
}
//-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
//{
//    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
//    if (self) {
//        self.Image1 = [[UIImageView alloc]init];
//        self.Image1.frame = CGRectMake(<#CGFloat x#>, <#CGFloat y#>, <#CGFloat width#>, <#CGFloat height#>)
//    }
//}

#pragma mark - 初始化


-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.floorview = [[[UIView alloc]init]autorelease];;
        [self.contentView addSubview:self.floorview];
        
        self.Image1 = [[[UIImageView alloc]init]autorelease];
        [self.floorview addSubview:self.Image1];
        
        self.Image2 = [[[UIImageView alloc]init]autorelease];
        [self.floorview addSubview:self.Image2];
        
        self.Image3 = [[[UIImageView alloc]init]autorelease];
        [self.floorview addSubview:self.Image3];
        
        self.Image4 = [[[UIImageView alloc]init]autorelease];
        [self.floorview addSubview:self.Image4];
        
        
        self.Image5 = [[[UIImageView alloc]init]autorelease];
        [self.floorview addSubview:self.Image5];
        
        
        self.Image6 = [[[UIImageView alloc]init]autorelease];
        [self.floorview addSubview:self.Image6];
        
        self.namelabel = [[[UILabel alloc]init]autorelease];
        [self.floorview addSubview:self.namelabel];
        
        self.informlabel = [[[UILabel alloc]init]autorelease];
        [self.floorview addSubview:self.informlabel];
        
        
        
    }
    return self;
}


#pragma mark - 布局farme


-(void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    //cell显示前 执行的方法
    self.floorview.frame = CGRectMake(SCREEN_WIDTH / 25, 0,SCREEN_WIDTH - SCREEN_WIDTH / 12.5, SCREEN_HEIGHT / 2.6);
    [self.floorview.layer setCornerRadius:10];
    //    self.floorview.frame = CGRectMake(15, 15, 300, 200);
    self.Image1.frame = CGRectMake(SCREEN_WIDTH / 48, SCREEN_WIDTH / 64, self.floorview.frame.size.width / 8 + SCREEN_WIDTH / 32, self.floorview.frame.size.width / 8 + SCREEN_WIDTH / 32) ;
    self.namelabel.frame = CGRectMake(SCREEN_WIDTH / 32 + self.Image1.frame.size.width + SCREEN_WIDTH / 48, SCREEN_WIDTH / 64, self.floorview.frame.size.width - SCREEN_WIDTH / 10.6 - self.Image1.frame.size.width, self.Image1.frame.size.height / 2 + SCREEN_WIDTH / 64);
    self.informlabel.frame = CGRectMake(SCREEN_WIDTH / 32 + self.Image1.frame.size.width + SCREEN_WIDTH / 48, SCREEN_WIDTH / 64 + self.Image1.frame.size.height / 2 + SCREEN_WIDTH / 64, self.floorview.frame.size.width - SCREEN_WIDTH / 8 - self.Image1.frame.size.width, self.Image1.frame.size.height / 2 - SCREEN_WIDTH / 64);
    // 左上
    self.Image2.frame = CGRectMake(self.floorview.frame.size.width - (self.floorview.frame.size.height / 3.2)  - (self.floorview.frame.size.height / 3.2) - SCREEN_WIDTH / 64, SCREEN_WIDTH / 64 + self.Image1.frame.size.height / 2 + SCREEN_WIDTH / 10.6, self.floorview.frame.size.height / 3.2, self.floorview.frame.size.height / 3.2);
    // 右上
    self.Image3.frame = CGRectMake(self.floorview.frame.size.width - (self.floorview.frame.size.height / 3.2), SCREEN_WIDTH / 64 + self.Image1.frame.size.height / 2 + SCREEN_WIDTH / 10.6, self.floorview.frame.size.height / 3.2, self.floorview.frame.size.height / 3.2);
    //左下
    self.Image4.frame = CGRectMake(self.floorview.frame.size.width - (self.floorview.frame.size.height / 3.2) - (self.floorview.frame.size.height / 3.2) - SCREEN_WIDTH / 64, SCREEN_WIDTH / 32 + self.Image1.frame.size.height / 2 + SCREEN_WIDTH / 10.6 + self.floorview.frame.size.height / 3.2 , self.floorview.frame.size.height / 3.2, self.floorview.frame.size.height / 3.2);
    
    //右下
    self.Image5.frame = CGRectMake(self.floorview.frame.size.width - (self.floorview.frame.size.height / 3.2), SCREEN_WIDTH / 64 + self.Image1.frame.size.height / 2 + SCREEN_WIDTH / 10.6 + self.floorview.frame.size.height / 3.2 + SCREEN_WIDTH / 64, self.floorview.frame.size.height / 3.2, self.floorview.frame.size.height / 3.2);
    
//    //正左侧 big的imageview
//    self.Image6.frame = CGRectMake(10 + SCREEN_WIDTH / 48 +self.floorview.frame.size.height / 3.2 + self.floorview.frame.size.height / 3.2, 20 + self.Image1.frame.size.height / 2 + 15, self.floorview.frame.size.height / 3.2 * 2 + 5, self.floorview.frame.size.height / 3.2 * 2 + 5);
    
    //正左侧 big的imageview
    self.Image6.frame = CGRectMake(self.floorview.frame.size.width - (self.floorview.frame.size.height / 3.2) - (self.floorview.frame.size.height / 3.2) - SCREEN_WIDTH / 32 - ( self.floorview.frame.size.height / 3.2 * 2 + SCREEN_WIDTH / 64), SCREEN_WIDTH / 64 + self.Image1.frame.size.height / 2 + SCREEN_WIDTH / 10.6, self.floorview.frame.size.height / 3.2 * 2 + SCREEN_WIDTH / 64, self.floorview.frame.size.height / 3.2 * 2 + SCREEN_WIDTH / 64);
    
//    self.namelabel.backgroundColor = [UIColor redColor];
//    self.informlabel.backgroundColor = [UIColor yellowColor];
    self.floorview.backgroundColor = RGBACOLOR(230, 230, 230, 1);
//    self.Image6.backgroundColor = [UIColor orangeColor];
//    self.Image5.backgroundColor = [UIColor orangeColor];
//    self.Image4.backgroundColor = [UIColor orangeColor];
//    self.Image3.backgroundColor = [UIColor orangeColor];
//    self.Image2.backgroundColor = [UIColor orangeColor];
//    self.Image1.backgroundColor = [UIColor orangeColor];
//    self.contentView.backgroundColor = [UIColor purpleColor];
    
}
#pragma mark - 赋值
-(void)setModel:(ClassifyModel *)Model
{
    if ( _Model != Model) {
        [_Model release];
        _Model = [Model retain];
    }
    
    
    [self.Image1 setImageWithURL:[NSURL URLWithString:Model.icon_url]];
    self.namelabel.text = Model.name;
    self.informlabel.text = Model.desc;
    [self.Image2 setImageWithURL:[NSURL URLWithString:Model.image_urls[0]]];
    [self.Image3 setImageWithURL:[NSURL URLWithString:Model.image_urls[1]]];
    [self.Image4 setImageWithURL:[NSURL URLWithString:Model.image_urls[2]]];
    [self.Image5 setImageWithURL:[NSURL URLWithString:Model.image_urls[3]]];
    [self.Image6 setImageWithURL:[NSURL URLWithString:Model.image_urls[4]]];
    
}

@end
